<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3_1_2-方法基础</title>
</head>

<body>


  <!--载入vue.js-->
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <h1>方法的基础</h1>
  <div id="Application">{{count}}</div>
  <script>
    //定义组件
    const App = {
      data() {
        return {
          count: "5",
        };
      },
      methods: {
        add() {
          this.count++;
        },
      },
    };

    //创建组件并获取组件实例
    let instance = Vue.createApp(App).mount("#Application");

    // 0
    console.log(instance.count);
    instance.add();

    // 1
    console.log(instance.count);
  </script>
</body>

</html>